import AxiosIns from './axiosSetting'
let ajaxMethod = ['get', 'post'];
let api = {};
ajaxMethod.forEach((method) => {
  //数组取值的两种方式
  api[method] = function (uri, data) {
    return new Promise(function (resolve, reject) {
      AxiosIns[method](uri, data).then(res => {
        if (!res.data.errCode) {
          resolve(res);
        } else {
          console.log(res.data);
          if (res.data.errCode == 10001) {
            setTimeout(() => {
              window.location.href = "/login"
            }, 500)

          }
        }
      }).catch((response) => {})
    })
  }
});
export default api;